package com.iplant.wms.service.po.mrp;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.wms.service.basicenum.mrp.MRPDeliveryStatus;

import java.io.Serializable;
import java.util.*;

/**
 * 物料配送需求
 *
 * @author femi
 * @CreateTime 2022-3-8 11:02:07
 */

@DBBasePO(TableName = "mrp_delivery_item", Schemas = DBSchemas.WMS, Name = false,
        CheckName = {"Code", "OrderID,RoutePartPointID,StationID,MaterialID,DemandDate"
                , "DeliveryID,RoutePartPointID,StationID"},
        CodeAuto = true, CodePrefix = "MRD-{yyMMdd}-")
public class MRPDeliveryItem extends BasePO implements Serializable {
    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    @DBCondition
    @DBField
    public int DeliveryID = 0;

    /**
     * 工厂ID
     */
    @DBCondition
    @DBField
    public int FactoryID = 0;
    /**
     * 工厂名称
     */
    @DBJoin(name = "Name", tableName = "fmc_factory", tableAsName = "fmc_factory1", Schemas = DBSchemas.Basic,
            MainTableField = "FactoryID")
    public String FactoryName = "";
    /**
     * 工厂编码
     */
    @DBJoin(name = "Code", tableName = "fmc_factory", tableAsName = "fmc_factory1", Schemas = DBSchemas.Basic,
            MainTableField = "FactoryID")
    public String FactoryCode = "";

    /**
     * 车型ID
     */
    @DBCondition
    @DBField(CheckValue = true)
    public int ProductID = 0;
    @DBField
    public String ProductCode = "";

    @DBField
    public String ProductName = "";

    @DBCondition
    @DBField(CheckValue = true)
    public int LineID = 0;

    @DBField
    public String LineName = "";

    @DBField
    public String LineCode = "";

    @DBCondition
    @DBField
    public int CustomerID = 0;
    /**
     * 客户名称
     */
    @DBJoin(name = "Name", tableName = "crm_customer", tableAsName = "crm_customer1", Schemas = DBSchemas.Basic,
            MainTableField = "CustomerID")
    public String CustomerName = "";
    /**
     * 客户编码
     */
    @DBJoin(name = "Code", tableName = "crm_customer", tableAsName = "crm_customer1", Schemas = DBSchemas.Basic,
            MainTableField = "CustomerID")
    public String CustomerCode = "";

    /**
     * 工件号（广机：车号）
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBField
    public String PartNo = "";

    /**
     * 订单ID
     */
    @DBCondition
    @DBField
    public int OrderID = 0;

    @DBCondition
    @DBField
    public String OrderNo = "";

    /**
     * 项目号
     */
    @DBCondition
    @DBField
    public String WBSNo = "";

    /**
     * 工艺ID
     */
    @DBCondition
    @DBField
    public int RoutePartID = 0;
    /**
     * 工位名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBField
    public String RoutePartName = "";


    /**
     * 工序ID
     */
    @DBCondition
    @DBField
    public int RoutePartPointID = 0;
    /**
     * 工序名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBField
    public String RoutePartPointName = "";


    /**
     * 车间ID
     */
    @DBCondition
    @DBField
    public int WorkShopID = 0;
    @DBJoin(name = "Name", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopName = "";
    /**
     * 车间编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopCode = "";

    /**
     * 工区ID
     */
    @DBCondition
    @DBField
    public int WorkAreaID = 0;
    /**
     * 工区名称
     */
    @DBJoin(name = "Name", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaName = "";
    /**
     * 工区编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaCode = "";

    @DBField
    public Map<String, Float> StationNumMap = new HashMap<>();


    @DBField
    public Map<String, Double> SetCapacityMap = new HashMap<>();
    /**
     * 工位ID
     */
    @DBCondition
    @DBField
    public List<Integer> StationID = new ArrayList<>();
    /**
     * 工位名称
     */
    @DBJoinMulti(Name = "Name", MainTableField = "StationID", TableName = "fmc_station", Schemas = DBSchemas.Basic
    )
    public String StationName = "";

    /**
     * 工位编码
     */
    @DBJoinMulti(Name = "Code", MainTableField = "StationID",
            TableName = "fmc_station", Schemas = DBSchemas.Basic)
    public String StationCode = "";

    /**
     * 物料ID
     */
    @DBCondition
    @DBField
    public int MaterialID = 0;
    /**
     * 物料编码
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "mss_material", tableAsName = "m2", Schemas = DBSchemas.Basic,
            MainTableField = "MaterialID")
    public String MaterialCode = "";

    /**
     * 物料名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "MaterialName", tableName = "mss_material", tableAsName = "m2", Schemas = DBSchemas.Basic,
            MainTableField = "MaterialID")
    public String MaterialName = "";
    /**
     * 物料类型ID
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "MaterialTypeID", tableName = "mss_material", tableAsName = "m2", Schemas = DBSchemas.Basic,
            MainTableField = "MaterialID")
    public int MaterialTypeID = 0;


    @DBCondition
    @DBJoin(name = "MaterialGroupID", tableName = "mss_material", tableAsName = "m2", JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, MainTableField = "MaterialID")
    public int MaterialGroupID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "mss_materialgroup", tableAsName = "m1",
            JoinIndex = 3, JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, ConditionalJoin = "m2.MaterialGroupID=m1.ID")
    public String MaterialGroupCode = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "mss_materialgroup", tableAsName = "m1",
            JoinIndex = 3, JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, ConditionalJoin = "m2.MaterialGroupID=m1.ID")
    public String MaterialGroupName = "";


    @DBCondition(CompareType = DBCondition.DBCompareType.leftLike)
    @DBJoin(name = "FullGroupName", tableName = "mss_materialgroup", tableAsName = "m1",
            JoinIndex = 3, JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, ConditionalJoin = "m2.MaterialGroupID=m1.ID")
    public String MaterialFullGroup = "";

    /**
     * 物料类型名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "mss_materialtype", tableAsName = "mt1",
            JoinIndex = 4, JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, ConditionalJoin = "m2.MaterialTypeID=mt1.ID")
    public String MaterialTypeName = "";

    /**
     * 物料类型名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "mss_materialtype", tableAsName = "mt1",
            JoinIndex = 4, JoinMode = DBJoin.DBJoinMode.Inner,
            Schemas = DBSchemas.Basic, ConditionalJoin = "m2.MaterialTypeID=mt1.ID")
    public String MaterialTypeCode = "";


    @DBField
    public int UnitID = 0;
    @DBJoin(name = "Code", tableName = "mss_unit", tableAsName = "un1", JoinMode = DBJoin.DBJoinMode.Left,
            Schemas = DBSchemas.Basic, MainTableField = "UnitID")
    public String UnitCode = "";
    @DBJoin(name = "Name", tableName = "mss_unit", tableAsName = "un1", JoinMode = DBJoin.DBJoinMode.Left,
            Schemas = DBSchemas.Basic, MainTableField = "UnitID")
    public String UnitText = "";
    /**
     * 需求数量
     */

    @DBField
    public double PlanFQTY = 0.0;


    /**
     * 定额物料数
     */
    @DBField
    public double StandardNum = 0.0f;


    /**
     * 当日计划数
     */
    @DBField
    public double OrderPlan = 0.0f;

    /**
     * 需求已完成数量
     */
    @DBField
    public double FQTYDone = 0.0;
    /**
     * 需求日期
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLt, ParamName = "DemandDateStart", ParamName2 = "DemandDateEnd")
    @DBField
    public Calendar DemandDate = Calendar.getInstance();


    /**
     * 必换偶换
     */
    @DBCondition
    @DBField
    public int ReplaceType = 0;

    @DBCondition
    @DBField
    public int OutSourceType = 0;

    /**
     * 状态
     */
    @DBCondition
    @DBField
    public int Status = 0;
    /**
     * 状态文本
     */
    public String StatusText = "";


    /**
     * 原拆原装要求 X/空
     */
    @DBCondition
    @DBField
    public int OriginalType = 0;

    /**
     * 评估类型
     */
    @DBCondition
    @DBField
    public int DisassyType = 0;

    public MRPDeliveryItem() {

        super();
    }


    @JsonProperty("FactoryID")
    public int getFactoryID() {
        return FactoryID;
    }

    public void setFactoryID(int factoryID) {
        FactoryID = factoryID;
    }

    @JsonProperty("FactoryName")
    public String getFactoryName() {
        return FactoryName;
    }

    public void setFactoryName(String factoryName) {
        FactoryName = factoryName;
    }

    @JsonProperty("FactoryCode")
    public String getFactoryCode() {
        return FactoryCode;
    }

    public void setFactoryCode(String factoryCode) {
        FactoryCode = factoryCode;
    }

    @JsonProperty("ProductID")
    public int getProductID() {
        return ProductID;
    }

    public void setProductID(int productID) {
        ProductID = productID;
    }

    @JsonProperty("ProductCode")
    public String getProductCode() {
        return ProductCode;
    }

    public void setProductCode(String productCode) {
        ProductCode = productCode;
    }

    @JsonProperty("ProductName")
    public String getProductName() {
        return ProductName;
    }

    public void setProductName(String productName) {
        ProductName = productName;
    }

    @JsonProperty("LineID")
    public int getLineID() {
        return LineID;
    }

    public void setLineID(int lineID) {
        LineID = lineID;
    }

    @JsonProperty("LineName")
    public String getLineName() {
        return LineName;
    }

    public void setLineName(String lineName) {
        LineName = lineName;
    }

    @JsonProperty("LineCode")
    public String getLineCode() {
        return LineCode;
    }

    public void setLineCode(String lineCode) {
        LineCode = lineCode;
    }

    @JsonProperty("CustomerID")
    public int getCustomerID() {
        return CustomerID;
    }

    public void setCustomerID(int customerID) {
        CustomerID = customerID;
    }

    @JsonProperty("CustomerName")
    public String getCustomerName() {
        return CustomerName;
    }

    public void setCustomerName(String customerName) {
        CustomerName = customerName;
    }

    @JsonProperty("CustomerCode")
    public String getCustomerCode() {
        return CustomerCode;
    }

    public void setCustomerCode(String customerCode) {
        CustomerCode = customerCode;
    }

    @JsonProperty("PartNo")
    public String getPartNo() {
        return PartNo;
    }

    public void setPartNo(String partNo) {
        PartNo = partNo;
    }

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("OrderNo")
    public String getOrderNo() {
        return OrderNo;
    }

    public void setOrderNo(String orderNo) {
        OrderNo = orderNo;
    }

    @JsonProperty("WBSNo")
    public String getWBSNo() {
        return WBSNo;
    }

    public void setWBSNo(String WBSNo) {
        this.WBSNo = WBSNo;
    }

    @JsonProperty("RoutePartID")
    public int getRoutePartID() {
        return RoutePartID;
    }

    public void setRoutePartID(int routePartID) {
        RoutePartID = routePartID;
    }

    @JsonProperty("RoutePartName")
    public String getRoutePartName() {
        return RoutePartName;
    }

    public void setRoutePartName(String routePartName) {
        RoutePartName = routePartName;
    }

    @JsonProperty("RoutePartPointID")
    public int getRoutePartPointID() {
        return RoutePartPointID;
    }

    public void setRoutePartPointID(int routePartPointID) {
        RoutePartPointID = routePartPointID;
    }

    @JsonProperty("RoutePartPointName")
    public String getRoutePartPointName() {
        return RoutePartPointName;
    }

    public void setRoutePartPointName(String routePartPointName) {
        RoutePartPointName = routePartPointName;
    }

    @JsonProperty("MaterialID")
    public int getMaterialID() {
        return MaterialID;
    }

    public void setMaterialID(int materialID) {
        MaterialID = materialID;
    }

    @JsonProperty("MaterialCode")
    public String getMaterialCode() {
        return MaterialCode;
    }

    public void setMaterialCode(String materialCode) {
        MaterialCode = materialCode;
    }

    @JsonProperty("MaterialName")
    public String getMaterialName() {
        return MaterialName;
    }

    public void setMaterialName(String materialName) {
        MaterialName = materialName;
    }

    @JsonProperty("MaterialTypeID")
    public int getMaterialTypeID() {
        return MaterialTypeID;
    }

    public void setMaterialTypeID(int materialTypeID) {
        MaterialTypeID = materialTypeID;
    }

    @JsonProperty("MaterialGroupID")
    public int getMaterialGroupID() {
        return MaterialGroupID;
    }

    public void setMaterialGroupID(int materialGroupID) {
        MaterialGroupID = materialGroupID;
    }

    @JsonProperty("MaterialGroupCode")
    public String getMaterialGroupCode() {
        return MaterialGroupCode;
    }

    public void setMaterialGroupCode(String materialGroupCode) {
        MaterialGroupCode = materialGroupCode;
    }

    @JsonProperty("MaterialGroupName")
    public String getMaterialGroupName() {
        return MaterialGroupName;
    }

    public void setMaterialGroupName(String materialGroupName) {
        MaterialGroupName = materialGroupName;
    }

    @JsonProperty("MaterialFullGroup")
    public String getMaterialFullGroup() {
        return MaterialFullGroup;
    }

    public void setMaterialFullGroup(String materialFullGroup) {
        MaterialFullGroup = materialFullGroup;
    }

    @JsonProperty("MaterialTypeName")
    public String getMaterialTypeName() {
        return MaterialTypeName;
    }

    public void setMaterialTypeName(String materialTypeName) {
        MaterialTypeName = materialTypeName;
    }

    @JsonProperty("MaterialTypeCode")
    public String getMaterialTypeCode() {
        return MaterialTypeCode;
    }

    public void setMaterialTypeCode(String materialTypeCode) {
        MaterialTypeCode = materialTypeCode;
    }

    @JsonProperty("DeliveryID")
    public int getDeliveryID() {
        return DeliveryID;
    }

    public void setDeliveryID(int deliveryID) {
        DeliveryID = deliveryID;
    }

    @JsonProperty("FQTY")
    public double getPlanFQTY() {
        return PlanFQTY;
    }

    public void setPlanFQTY(double planFQTY) {
        this.PlanFQTY = planFQTY;
    }

    @JsonProperty("DemandDate")
    public Calendar getDemandDate() {
        return DemandDate;
    }

    public void setDemandDate(Calendar demandDate) {
        DemandDate = demandDate;
    }

    @JsonProperty("ReplaceType")
    public int getReplaceType() {
        return ReplaceType;
    }

    public void setReplaceType(int replaceType) {
        ReplaceType = replaceType;
    }

    @JsonProperty("OutSourceType")
    public int getOutSourceType() {
        return OutSourceType;
    }

    public void setOutSourceType(int outSourceType) {
        OutSourceType = outSourceType;
    }

    @JsonProperty("OriginalType")
    public int getOriginalType() {
        return OriginalType;
    }

    public void setOriginalType(int originalType) {
        OriginalType = originalType;
    }

    @JsonProperty("DisassyType")
    public int getDisassyType() {
        return DisassyType;
    }

    public void setDisassyType(int disassyType) {
        DisassyType = disassyType;
    }


    public void setStationCode(String stationCode) {
        StationCode = stationCode;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("StatusText")
    public String getStatusText() {
        StatusText = MRPDeliveryStatus.getEnumType(Status).getLabel();
        return StatusText;
    }

    public void setStatusText(String statusText) {
        StatusText = statusText;
    }

    @JsonProperty("FQTYDone")
    public double getFQTYDone() {
        return FQTYDone;
    }

    public void setFQTYDone(double FQTYDone) {
        this.FQTYDone = FQTYDone;
    }

    @JsonProperty("WorkShopID")
    public int getWorkShopID() {
        return WorkShopID;
    }

    public void setWorkShopID(int workShopID) {
        WorkShopID = workShopID;
    }

    @JsonProperty("WorkShopName")
    public String getWorkShopName() {
        return WorkShopName;
    }

    public void setWorkShopName(String workShopName) {
        WorkShopName = workShopName;
    }

    @JsonProperty("WorkShopCode")
    public String getWorkShopCode() {
        return WorkShopCode;
    }

    public void setWorkShopCode(String workShopCode) {
        WorkShopCode = workShopCode;
    }

    @JsonProperty("WorkAreaID")
    public int getWorkAreaID() {
        return WorkAreaID;
    }

    public void setWorkAreaID(int workAreaID) {
        WorkAreaID = workAreaID;
    }

    @JsonProperty("WorkAreaName")
    public String getWorkAreaName() {
        return WorkAreaName;
    }

    public void setWorkAreaName(String workAreaName) {
        WorkAreaName = workAreaName;
    }

    @JsonProperty("WorkAreaCode")
    public String getWorkAreaCode() {
        return WorkAreaCode;
    }

    public void setWorkAreaCode(String workAreaCode) {
        WorkAreaCode = workAreaCode;
    }

    @JsonProperty("StationNumMap")
    public Map<String, Float> getStationNumMap() {
        return StationNumMap;
    }

    public void setStationNumMap(Map<String, Float> stationNumMap) {
        StationNumMap = stationNumMap;
    }

    @JsonProperty("SetCapacityMap")
    public Map<String, Double> getSetCapacityMap() {
        return SetCapacityMap;
    }

    public void setSetCapacityMap(Map<String, Double> setCapacityMap) {
        SetCapacityMap = setCapacityMap;
    }

    @JsonProperty("StationID")
    public List<Integer> getStationID() {
        return StationID;
    }

    public void setStationID(List<Integer> stationID) {
        StationID = stationID;
    }

    @JsonProperty("StationName")
    public String getStationName() {
        return StationName;
    }

    public void setStationName(String stationName) {
        StationName = stationName;
    }

    @JsonProperty("StationCode")
    public String getStationCode() {
        return StationCode;
    }

    @JsonProperty("StandardNum")
    public double getStandardNum() {
        return StandardNum;
    }

    public void setStandardNum(double standardNum) {
        StandardNum = standardNum;
    }


    @JsonProperty("UnitID")
    public int getUnitID() {
        return UnitID;
    }

    public void setUnitID(int unitID) {
        UnitID = unitID;
    }

    @JsonProperty("UnitCode")
    public String getUnitCode() {
        return UnitCode;
    }

    public void setUnitCode(String unitCode) {
        UnitCode = unitCode;
    }

    @JsonProperty("UnitText")
    public String getUnitText() {
        return UnitText;
    }

    public void setUnitText(String unitText) {
        UnitText = unitText;
    }

    @JsonProperty("OrderPlan")
    public double getOrderPlan() {
        return OrderPlan;
    }

    public void setOrderPlan(double orderPlan) {
        OrderPlan = orderPlan;
    }
}
